<template>
	<view class="continer">
		<u-toast ref="uToast" />
		<view class="u-text-center tip u-font-15">
			请确认操作结果，确认无误将为您处理{{type=="1"?"分拨":"回拨"}}
		</view>
		<view class="content">
			<view class="u-border-bottom flex justify-between item align-center">
				<view class="">
					已选终端
				</view>
				<view class="color">
					{{size}}台
				</view>
			</view>
			<view class="flex justify-between item align-center">
				<view class="">
					{{type=="1"?"分拨":"回拨"}}对象
				</view>
				<view>
					{{userName}}
				</view>
			</view>
		</view>
		<u-button class="u-margin-20 u-margin-top-50" type="primary" hover-class="false" :custom-style="customStyle"
			@click="check()">确认{{type=="1"?"分拨":"回拨"}}</u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customStyle: {
					// 注意驼峰命名，并且值必须用引号包括，因为这是对象
					backgroundColor: '#9D60FF'
				},
				requstBody: {
					agentNo: "",
					sn: ""
				},
				size: "",
				type: "",
				userName: ""
			}
		},
		onLoad(options) {
			options.type && (this.type = options.type);
			options.sn && (this.requstBody.sn = options.sn);
			options.size && (this.size = options.size);
			options.agentNo && (this.requstBody.agentNo = options.agentNo);
			options.userName && (this.userName = options.userName);
		},

		methods: {
			check() {
				if (this.type == '1') {
					this.goAllocate();
				} else {
					this.goTerminalSNRecover();
				}
			},
			goAllocate() {
				let _that = this;

				_that.$zx.terminal_api.terminalSNIssue(this.requstBody).then((
					data) => {

					console.log("data=" + JSON.stringify(data))
					_that.$refs.uToast.show({
						title: '操作成功',

					})
					uni.navigateBack({
						delta: 3
					});
				});
			},
			goTerminalSNRecover() {
				let _that = this;
				_that.$zx.terminal_api.terminalSNRecover(this.requstBody).then((
					data) => {

					console.log("data=" + JSON.stringify(data))
					_that.$refs.uToast.show({
						title: '操作成功',

					})
					uni.navigateBack({
						delta: 3
					});
				});
			}
		},
	}
</script>

<style scoped lang="scss">
	.tip {
		height: 80rpx;
		line-height: 80rpx;
		background-color: #FFE9CE;
		color: #FFA300;
	}

	.color {
		color: #9D60FF
	}

	.content {
		background-color: white;
		border-radius: 10rpx;
		padding: 0 20rpx;
		margin: 20rpx;

		.item {
			height: 120rpx;

		}
	}
</style>